package com.acme.concurrent.point;

import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * @author Gregory Sobko
 */
public class TrackerDelegate {
    private final ConcurrentMap<String, Point> locations;
    private final Map<String, Point> unmodifiableLocations;

    public TrackerDelegate(Map<String, Point> locations) {
        this.locations = new ConcurrentHashMap<String, Point>(locations);
        unmodifiableLocations = Collections.unmodifiableMap(locations);
    }

    public Point getLocation(String id){
        return locations.get(id);
    }

    public Map<String, Point> getLocations(){
        return unmodifiableLocations;
    }

    public void setLocation(String id, Point point){
        locations.put(id, point);
    }

}
